package com.example.controller;

import com.example.entity.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/7/20 15:33
 */
@Controller
@RequestMapping("/test")
public class TestController {

    @Autowired
    UserService userService;

    @RequestMapping("/test01")
    public String method01(){
        System.out.println("Spring MVC 成功!");
        return "test02";
    }

    @RequestMapping("/test02")
    public void method02(String name){
        System.out.println("name:" + name);
        List<User> all = userService.findAll();
        for (User user : all) {
            System.out.println(user);
        }
    }

}
